package gov.child.dao;

import gov.child.dao.exception.EntityDeleteException;
import gov.child.dao.exception.EntityQueryException;
import gov.child.dao.exception.EntitySaveException;
import gov.child.dao.exception.EntityUpdateException;
import gov.child.entities.po.EDepartment;
import gov.child.entities.po.EGuide;
import gov.child.entities.vo.Page;

import java.util.List;

/**
 * The interface Guide dao.
 *
 * @author fzh
 * @since 2017 /9/10
 */
public interface GuideDao extends Pageable{

    List find(EDepartment department, Boolean online, Byte ... obj);

    /**
     * 查询所有
     *
     * @return the all
     * @throws EntityQueryException the entity query exception
     */
    default List findAll() throws EntityQueryException {
        return findAll(Page.singlePage());
    }

    /**
     * 查询所有（分页）
     *
     * @param page the page
     * @return the all
     * @throws EntityQueryException the entity query exception
     */
    List findAll(Page page) throws EntityQueryException;

    /**
     * 根据ID查询
     *
     * @param id the id
     * @return the by id
     * @throws EntityQueryException the entity query exception
     */
    EGuide findById(Integer id) throws EntityQueryException;

    /**
     * 根据部门查找指南
     *
     * @param department the department
     * @return the by department
     * @throws EntityQueryException the entity query exception
     */
    default List findByDepartment(EDepartment department) throws EntityQueryException {
        return findByDepartment(department, Page.singlePage());
    }

    /**
     * 根据部门查找指南（分页）
     *
     * @param department the department
     * @param page       the page
     * @return the by department
     * @throws EntityQueryException the entity query exception
     */
    default List findByDepartment(EDepartment department, Page page) throws EntityQueryException {
        return findByDepartmentId(department.getId(), page);
    }

    default List findByDepartmentId(Integer departmentId) {
        return findByDepartmentId(departmentId, Page.singlePage());
    }

    List findByDepartmentId(Integer departmentId, Page page);

    EGuide findByGuideCode(String code);

    /**
     * 根据办理对象（个人或企业...）查找
     *
     * @param obj the obj
     * @return the by obj
     * @throws EntityQueryException the entity query exception
     */
    default List findByObj(Byte obj) throws EntityQueryException {
        return findByObj(obj, Page.singlePage());
    }

    /**
     * 根据办理对象（个人或企业...）查找（分页）
     *
     * @param obj  the obj
     * @param page the page
     * @return the by obj
     * @throws EntityQueryException the entity query exception
     */
    List findByObj(Byte obj, Page page) throws EntityQueryException;

    /**
     * 根据是否支持在线办理查询
     *
     * @param online the online
     * @return the by online
     * @throws EntityQueryException the entity query exception
     */
    default List findByOnline(Byte online) throws EntityQueryException {
        return findByOnline(online, Page.singlePage());
    }

    /**
     * 根据是否支持在线办理查询（分页）
     *
     * @param online the online
     * @param page   the page
     * @return the by online
     * @throws EntityQueryException the entity query exception
     */
    List findByOnline(Byte online, Page page) throws EntityQueryException;

    /**
     * 保存Guide信息到数据库
     *
     * @param guide the guide
     * @throws EntitySaveException the entity save exception
     */
    void save(EGuide guide) throws EntitySaveException;

    /**
     * 删除Guide
     *
     * @param guide the guide
     * @throws EntityDeleteException the entity delete exception
     */
    void delete(EGuide guide) throws EntityDeleteException;

    /**
     * 更新Guide
     *
     * @param guide the guide
     * @throws EntityUpdateException the entity update exception
     */
    void update(EGuide guide) throws EntityUpdateException;
}
